﻿@model Post
<article class="article article-type-post" itemscope itemprop="blogPost">
    <div class="article-meta @(Html.IsAdmin() ? "admin" : "")">
        @if (Html.IsAdmin())
        {
            <a href="javascript:$('#frmDeletePost').submit();"><i class="fa fa-trash"></i> 删除</a>@(new HtmlString("&nbsp; &nbsp; &nbsp;"))
            <a href="javascript:DropEnable();$('.post-body').slideUp();$('.post-edit').slideDown();"><i class="fa fa-pencil"></i> 编辑</a>@(new HtmlString("&nbsp; &nbsp; &nbsp;"))
        }
        <a href="/post/@Model.Url" class="article-date">
            <time datetime="@Model.Time.ToString()" itemprop="datePublished">@Model.Time.ToString("yyyy年MM月dd日 HH:mm")</time>
        </a>
    </div>
    <div class="article-inner">
        <input type="hidden" class="isFancy" />
        <header class="article-header">
            <h1 itemprop="name">
                <a class="article-title" href="/post/@Model.Url">@Model.Title</a>
            </h1>
        </header>
        <div class="article-entry" itemprop="articleBody">
            <div class="post-body">
                @Html.Marked(Model.Content)
            </div>
            @if (Html.IsAdmin())
            {
                <form id="frmDeletePost" asp-action="PostDelete" asp-controller="Admin" method="post" asp-route-id="@Model.Url"></form>
                <form asp-action="PostEdit" asp-controller="Admin" method="post" id="frmSavePost"></form>

                <div class="post-edit">
                    <p><input class="textbox w-3" id="txtTitle" type="text" placeholder="@SR["Title"]" value="@Model.Title" /></p>
                    <p><input class="textbox w-3" id="txtUrl" type="text" placeholder="URL" value="@Model.Url" /></p>
                    <p>
                        <select id="lstCatalogs">
                            <option value="">未分类</option>
                            @foreach (CatalogViewModel c in ViewBag.Catalogs)
                            {
                                <!option value="@c.Id" @(Model.CatalogId == c.Id ? "selected" : "")>@c.Title</!option>
                            }
                        </select>
                    </p>
                    <p>
                        <div class="markdown-textbox-outer">
                            <textarea id="txtContent" class="markdown-textbox" name="Content" placeholder="Markdown here...">@(new HtmlString(Model.Content))</textarea>
                            <div class="markdown-textbox-bottom">拖拽文件、粘贴文件或<a href="javascript:uploadAttachment();">选择文件</a>以添加附件。</div>
                        </div>
                    </p>
                    <form id="frmAjaxUpload">
                        <input type="file" id="uploadFile" name="file" />
                    </form>
                    <p>
                        <input class="textbox w-3" type="text" id="txtTags" placeholder="@SR["Use a ',' to split tags"]" value="@Html.TagSerialize(Model.Tags)" />
                    </p>
                    <p>
                        <input type="checkbox" id="chkIsPage" @(Model.IsPage ? "checked" : "") /> 是否为页面
                    </p>
                    <p>
                        <input class="button button-def" type="button" id="btnSavePost" onclick="savePost('@Model.Url')" value="保存" class="more-link" />
                        <input type="button" class="button" onclick="$('.post-edit').slideUp();$('.post-body').slideDown();" value="取消" />
                    </p>
                </div>
            }
        </div>
        <div class="article-info article-info-index">
            <div class="article-tag tagcloud">
                <ul class="article-tag-list">
                    @foreach (PostTag y in Model.Tags)
                    {
                        <li class="article-tag-list-item"><a class="article-tag-list-link" asp-action="Tag" asp-controller="Home" asp-route-tag="@y.Tag">@y.Tag</a></li>
                    }
                </ul>
            </div>
            <div class="clearfix"></div>
        </div>
    </div>
</article>
<div id="disqus-outer">
    <div id="disqus_thread">
        <script type="text/javascript">
            /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
            var disqus_shortname = '@ViewBag.Disqus'; // required: replace example with your forum shortname

            /* * * DON'T EDIT BELOW THIS LINE * * */
            (function () {
                var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
                dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
                (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
            })();
        </script>
    </div>
</div>